Ext.define('App.metric.project.view.IterationReport', {
    extend: 'Ext.tab.Panel',
    requires: ['App.project.view.ProjectFormPanel'],
    alias: ['widget.IterationReport'],
    userCls: 'while-header-tab',
    tabBar:{height:45,defaults:{height:45,minWidth:100}},
    listeners:
        {
            afterrender: function () {
                var me = this;
                me.loadReportConfiguration();
            }
        },
    loadReportConfiguration: function () {
        var me = this;
        me.mask('加载报表...');
        Ext.Ajax.request({
            url: 'report_configuration/query_iteration_report_configuration_baseinfo',
            params: {projectId: me.node.data.id},
            success: function (resp) {
                var rcs = resp.result.data;
                if (Ext.isArray(rcs)) {
                    Ext.Array.each(rcs, function (reportConfiguration) {
                        var interations = [];
                        Ext.Array.each(me.node.data.iterations, function (iteration) {
                            interations.push(iteration.id);
                        });
                        var report = Ext.create({
                            xtype: 'Report',
                            title: reportConfiguration.name=='关键指标'?null:reportConfiguration.name,
                            reportConfigurationId: reportConfiguration.id,
                            projectId: me.node.data.id
                        })
                        if (reportConfiguration.name == '关键指标') {
                            report.margin = '10 0 0 0'
                            me.down('ProjectFormPanel').add(report);
                        } else {
                            me.add(report);
                        }
                    })
                }
                me.unmask();
            },
            failure: function () {
                me.unmask();
            }
        });
    },
    items: [
        {
            xtype: 'ProjectFormPanel',
            title: '项目信息'
        }
    ]
})